/**
 * 公司实时资金
 */
app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http){
    console.log('------$scope.menuId1-----', $scope.menuId);
    console.log('------$scope.buttonArr1-----', $scope.buttonArr);


    $scope.bindBtn = function(event) {
        var datas = $scope.getSelectedRows();
        switch(event){

            case 'event-to-updateFzed'://修改负载额度
            {
                if(datas.length == 0) {
                    layer.alert('尚未选中数据');
                } else if(datas.length > 1) {
                    layer.alert('只能选中一行数据');
                } else {
                    var w = ($(window).width() * 0.3);
                    var h = ($(window).height() * 0.4);
                    layer.open({
                        shadeClose:true,
                        area: [w + 'px', h + 'px'],
                        title: '负债额度',
                        content: `
								<form class="layui-form">
								  <div class="layui-form-item">
								  	 <label class="layui-form-label">公司编码</label>
    								 <div class="layui-input-block">
									 	<input type="text" class="layui-input" value="`+datas[0].vGsBm+`" readonly>
									 </div>
								  </div>
								  <div class="layui-form-item">
									<label class="layui-form-label">公司简称</label>
									<div class="layui-input-block">
									  <input type="text" value="`+datas[0].vGsJc+`" readonly class="layui-input">
									</div>
								  </div>
								  <div class="layui-form-item">
									<label class="layui-form-label">负债额度</label>
									<div class="layui-input-block">
									  <input type="number" name="fFzEd" id="fFzEd" lay-verify="required" placeholder="请输入负债额度" value="`+datas[0].fFzEd+`" class="layui-input">
									</div>
								  </div>
								</form>
							`,
                        success: function(layero, index) {},
                        yes: function (index, layero) {
                            layer.msg('处理中', {
                                icon: 16,shade: 0.01
                            });
                            var fFzEd = $('#fFzEd').val();
                            var vgsbm = datas[0].vGsBm;

                            $http.post('/api/inter/tcwAccountCountForCompany/updateFzed', {}, {params: {vgsbm: vgsbm, fFzEd:fFzEd}})
                                .success(function (data) {
                                    if (data.code == 0) {
                                        layer.msg(data.msg);
                                        setTimeout(function(){
                                            layer.closeAll();
                                            location.reload();
                                        }, 3000);
                                    } else {
                                        layer.closeAll();
                                        layer.msg(data.msg);
                                    }
                                })
                                .error(function(result){
                                    layer.close();
                                    layer.msg("操作失败，请稍后再试！", {icon: 2});
                                });
                        }
                    });
                }
                break;
            }

        };
    }
}

